home *** CD-ROM | disk | FTP | other *** search
- Path: snews.tcel.com!netway
- From: tech@netway.ab.ca (Ritchie Annand)
- Newsgroups: comp.lang.c++
- Subject: Re: Function Prototypes in C++
- Date: 5 Apr 1996 10:41:18 GMT
- Organization: Telnet Canada (403) 262-5859 info@tcel.com
- Message-ID: <4k2tce$99u@challenge.tcel.com>
- References: <4junnq$2k1@phoenix.csc.calpoly.edu>
- NNTP-Posting-Host: 204.209.150.53
- X-Newsreader: News Xpress Version 1.0 Beta #4
-
- In article <4junnq$2k1@phoenix.csc.calpoly.edu>,
- nbonfili@phoenix.csc.calpoly.edu (Nicholas R Bonfilio) wrote:
- >I know that function prototypes are required in standard C++ as opposed to C
- >where they are not required. But, what I don't know for certain is the
- >rules regarding the scoping of function protos...
-
- You don't need a function prototype if you've fully-defined the function by
- the time you reach main() (you can put the functions above main in the
- source). For those cases when you have a case of mutual use, or you put them
- after main, the prototypes must come outside of a function, before any
- functions that need to use it. (Note: this way, you can separate out the
- header and implementation into .hpp/.cpp)
-
- Mind you, most C++ programming, you'll want to do with classes. In that
- case, the whole class definition with method prototypes is like a list of
- function prototypes (with thisClassName:: on the front) - that goes in the
- hpp file, and the implementation that uses those methods goes in the .cpp
- file (usually), so you don't need to make any "extra" prototypes for the
- methods inside classes.
-
- --=- Ritchie A.
-